fix(desktop): attach OS file drops instead of inserting their paths - #6934
Open
Muammer06 wants to merge 2 commits into
Open
fix(desktop): attach OS file drops instead of inserting their paths#6934Muammer06 wants to merge 2 commits into
Muammer06 wants to merge 2 commits into
Conversation
Linux WebKitGTK (and some other webviews) deliver file-manager drops as file:// URIs or absolute paths instead of File objects. ProseMirror then inserts the path as composer text. Claim those drops in editorProps.handleDrop, recover paths from text/uri-list, and upload them through the same TOCTOU-safe pipeline as the paperclip picker. Signed-off-by: Muammer <muammer@clonifylabs.com>
WebKitGTK on GNOME/Wayland advertises Files on dragover then delivers an empty dataTransfer on drop. Ignore dummy File objects, set dropEffect=copy, and read the real paths from GTK drag-data-received. Signed-off-by: Muammer <muammer@clonifylabs.com>
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #6933
Problem
Dragging a photo or file from the OS file manager into the composer inserts the filesystem path as chat text instead of attaching the file. Reproduced on Linux WebKitGTK against a self-hosted relay.
Paperclip + clipboard image paste already work. Drop does not.
Cause
dragDropEnabledisfalse, so drops go to the webview.onDroponly readsdataTransfer.files.Fileobjects and instead deliverstext/uri-list/text/plainwithfile://…or an absolute path.editorProps.handleDrop, so it inserts that path as text.Fix
editorProps.handleDrop(message + forum composers) before ProseMirror inserts text, andstopPropagationso the form handler does not double-upload.text/uri-list/text/plainwhenfilesis empty (require a basename with an extension so/usr/bin/env pythonis not treated as a file).upload_dropped_mediacommand that uses the same TOCTOU-safeprocess_picked_pathpipeline as the paperclip picker (HEIC transcode, MIME deny-list, size caps).text/uri-listas a file drag for the drop overlay and windowpreventDefault(avoidsfile:///navigation).Tests
40 passed (15 new path/URI cases + existing slot tests).
Rust
validate_dropped_pathtests added; not compiled here (GTK syslibs missing on this machine).Manual test
just desktop-devor a local Tauri build./home/…/photo.pngin the input.No UI screenshots: behavior is drop → attach; the overlay already existed.
None found for this specific path-as-text bug; closest existing work is the form-level
handleDropthat only seesdataTransfer.files.